/*
 * Copyright (c) 2023, 2023,yzc.cn All rights reserved.
 *
 */
package cn.yzc;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;

import javax.servlet.MultipartConfigElement;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;

/**
 * <p>Project: SpringMVCPro - App</p>
 * <p>Powered by yzc On 2023-10-30 16:07:07</p>
 * <p>描述：<p>
 *
 * @author yzc [yzc0415@126.com]
 * @version 1.0
 * @since 17
 */

public class App implements WebApplicationInitializer {


    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        //spring 上下文
       AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
        //指定扫描的包
        context.scan("cn.yzc");
        // 注册DispatcherServlet 前端控制类
        DispatcherServlet dispatcherServlet  = new DispatcherServlet(context);
        ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", dispatcherServlet);
        dispatcher.setLoadOnStartup(1);
        dispatcher.addMapping("/");
        //处理文件上传
        dispatcher.setMultipartConfig(new MultipartConfigElement(""));

    }
}

